<template>
    <h3>登录</h3>
    <table border="1">
        <tr>
            <td>用户名：</td>
            <td><input type="text" v-model="info.UName"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" v-model="info.Upwd"></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="login">
            </td>
        </tr>

    </table>
</template>


<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'

const info=ref({
    UName:'',
    Upwd:''
})

const login=()=>{
    axios.get("http://localhost:2742/api/Finan/Login",{
       
        params:{
            UName:info.value.UName,
            Upwd:info.value.Upwd
        }
    })
    .then(res=>{
        if(res.data>0){
            alert("登录成功")
            location.href="/UserFinan"
        }
        else if(res.data==-2){
            alert("用户名不存在")
        }
        else if(res.data==-3)
        {
            alert("用户名或密码输入错误")
        }
        else{

            alert("登录失败")
        }
    })
}


</script>